|
1
|
|
|
/** global: browser */ |
|
2
|
|
|
/** global: Wappalyzer */ |
|
3
|
|
|
|
|
4
|
|
|
const wappalyzer = new Wappalyzer(); |
|
5
|
|
|
|
|
6
|
|
|
function getOption(name, defaultValue, callback) { |
|
7
|
|
|
browser.storage.local.get(name) |
|
8
|
|
|
.then(item => { |
|
9
|
|
|
callback(item.hasOwnProperty(name) ? item[name] : defaultValue); |
|
10
|
|
|
}); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
function setOption(name, value) { |
|
14
|
|
|
( chrome || browser ).runtime.sendMessage({ |
|
|
|
|
|
|
15
|
|
|
id: 'set_option', |
|
16
|
|
|
key: name, |
|
17
|
|
|
value: value |
|
18
|
|
|
}); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
22
|
|
|
var nodes = document.querySelectorAll('[data-i18n]'); |
|
23
|
|
|
|
|
24
|
|
|
Array.prototype.forEach.call(nodes, node => { |
|
25
|
|
|
node.childNodes[0].nodeValue = browser.i18n.getMessage(node.dataset.i18n); |
|
26
|
|
|
}); |
|
27
|
|
|
|
|
28
|
|
|
document.querySelector('#github').addEventListener('click', () => { |
|
29
|
|
|
open(wappalyzer.config.githubURL); |
|
30
|
|
|
}); |
|
31
|
|
|
|
|
32
|
|
|
document.querySelector('#twitter').addEventListener('click', () => { |
|
33
|
|
|
open(wappalyzer.config.twitterURL); |
|
34
|
|
|
}); |
|
35
|
|
|
|
|
36
|
|
|
document.querySelector('#wappalyzer').addEventListener('click', () => { |
|
37
|
|
|
open(wappalyzer.config.websiteURL); |
|
38
|
|
|
}); |
|
39
|
|
|
|
|
40
|
|
|
getOption('upgradeMessage', true, value => { |
|
41
|
|
|
const el = document.querySelector('#option-upgrade-message'); |
|
42
|
|
|
|
|
43
|
|
|
el.checked = value; |
|
44
|
|
|
|
|
45
|
|
|
el.addEventListener('change', () => { |
|
46
|
|
|
setOption('upgradeMessage', el.checked); |
|
47
|
|
|
}); |
|
48
|
|
|
}); |
|
49
|
|
|
|
|
50
|
|
|
getOption('dynamicIcon', true, value => { |
|
51
|
|
|
const el = document.querySelector('#option-dynamic-icon'); |
|
52
|
|
|
|
|
53
|
|
|
el.checked = value; |
|
54
|
|
|
|
|
55
|
|
|
el.addEventListener('change', () => { |
|
56
|
|
|
setOption('dynamicIcon', el.checked); |
|
57
|
|
|
}); |
|
58
|
|
|
}); |
|
59
|
|
|
|
|
60
|
|
|
getOption('tracking', true, value => { |
|
61
|
|
|
const el = document.querySelector('#option-tracking'); |
|
62
|
|
|
|
|
63
|
|
|
el.checked = value; |
|
64
|
|
|
|
|
65
|
|
|
el.addEventListener('change', () => { |
|
66
|
|
|
setOption('tracking', el.checked); |
|
67
|
|
|
}); |
|
68
|
|
|
}); |
|
69
|
|
|
}); |
|
70
|
|
|
|